﻿@model AntUnion.FrameWork.Model.Models.CrmGroup
@{
    ViewData["Title"] = "Create";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{
    <script type="text/javascript">
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'form'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , parentFrameIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引;

            /**多语言初始化 */
            top.SetFormPageLanguage(layui);

            /* 监听提交 */
            form.on('submit(submit-form)', function (data) {
                if ($("#Name").val() == "") {
                    top.AlertByKey(layui, "enterNames", 0);
                    return false;
                }
                if ($("#Sort").val() == "") {
                    top.AlertByKey(layui, "enterSort", 0);
                    return false;
                } else if (isNaN($("#Sort").val())) {
                    top.AlertByKey(layui, "sortNotIsNumber", 0);
                    return false;
                }
                $.ajax({
                    type: "POST",
                    url: "/Console/CRMGroup/Edit",
                    data: data.field, // 你的formid
                    async: true,
                    error: function (request) {
                        alert("Connection error");
                    },
                    beforeSend: function (xhr) {
                        layui.layer.load();
                    },
                    success: function (data) {
                        var item = eval(data);
                        if (item.code == 0) {
                            /**提示语弹框 */
                            top.ShowMessageByKey(layui, "submitSuccess", 6, 1000, function () {
                                parent.layer.close(parentFrameIndex);
                                parent.renderTable();
                            });
                        } else {
                            /**提示语弹框 */
                            top.AlertByKey(layui, "submitFail", 0);
                        }
                        layer.closeAll('loading');
                    }
                });
                return false;
            });

        });
    </script>
}

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="component-form-group">
                <div class="layui-form-item">
                    <label class="layui-form-label" lay-event="names">名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="Name" id="Name" value="@Model.Name" placeholder="enterNames" class="layui-input">
                        @Html.HiddenFor(m => m.Id)
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" lay-event="sort">排序</label>
                    <div class="layui-input-block">
                        <input type="number" name="Sort" id="Sort" value="@Model.Sort" placeholder="enterSort" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" lay-event="remark">备注</label>
                    <div class="layui-input-block">
                        <textarea name="Remark" id="Remark" placeholder="enterTypeRemark" class="layui-textarea">@Model.Remark</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button id="submitForm" class="layui-btn" lay-submit="" lay-filter="submit-form">立即提交</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>